<html>
<head><meta charset="utf-8"><title>default from impl · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html">default from impl</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="195233102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233102">(Apr 24 2020 at 19:20)</a>:</h4>
<p>How impossible would it be to get <code>impl&lt;T&gt; From&lt;T&gt; for T</code> marked as <code>default</code>?</p>



<a name="195233113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233113">(Apr 24 2020 at 19:20)</a>:</h4>
<p><a href="/user_uploads/4715/0dlMk0gyJplu6AwJxoYFZR-f/Screenshot-from-2020-04-24-12-18-40.png" title="Screenshot-from-2020-04-24-12-18-40.png">Screenshot-from-2020-04-24-12-18-40.png</a> <a href="/user_uploads/4715/0PW2GkwbjmzW40IOxVuilDLK/Screenshot-from-2020-04-24-12-18-26.png" title="Screenshot-from-2020-04-24-12-18-26.png">Screenshot-from-2020-04-24-12-18-26.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/0dlMk0gyJplu6AwJxoYFZR-f/Screenshot-from-2020-04-24-12-18-40.png" title="Screenshot-from-2020-04-24-12-18-40.png"><img src="/user_uploads/4715/0dlMk0gyJplu6AwJxoYFZR-f/Screenshot-from-2020-04-24-12-18-40.png"></a></div><div class="message_inline_image"><a href="/user_uploads/4715/0PW2GkwbjmzW40IOxVuilDLK/Screenshot-from-2020-04-24-12-18-26.png" title="Screenshot-from-2020-04-24-12-18-26.png"><img src="/user_uploads/4715/0PW2GkwbjmzW40IOxVuilDLK/Screenshot-from-2020-04-24-12-18-26.png"></a></div>



<a name="195233330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233330">(Apr 24 2020 at 19:22)</a>:</h4>
<p>Huh.</p>



<a name="195233335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233335">(Apr 24 2020 at 19:22)</a>:</h4>
<p>So, two things...</p>



<a name="195233409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233409">(Apr 24 2020 at 19:23)</a>:</h4>
<p>For the actual question, I think the folks who worked on min_specialization might be good folks to ask, as might <span class="user-mention" data-user-id="116009">@nikomatsakis</span>.</p>



<a name="195233427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233427">(Apr 24 2020 at 19:23)</a>:</h4>
<p>For the use case, though: it seems <em>really</em> unusual to me to have an <code>impl From&lt;T&gt; for T</code> instance that isn't an identity.</p>



<a name="195233454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233454">(Apr 24 2020 at 19:23)</a>:</h4>
<p>Calling <code>.into()</code> on a <code>ReturnTrace</code> would add the current location to the trace?</p>



<a name="195233520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233520">(Apr 24 2020 at 19:24)</a>:</h4>
<p>yea, the idea is that when you do <code>?</code> on an error that does the same thing as this type (was meant as a proof of concept) you'd get a backtrace of the return points</p>



<a name="195233553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233553">(Apr 24 2020 at 19:24)</a>:</h4>
<p><em>Ah</em>, I see.</p>



<a name="195233559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233559">(Apr 24 2020 at 19:24)</a>:</h4>
<p>this is probably not the right approach</p>



<a name="195233597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233597">(Apr 24 2020 at 19:24)</a>:</h4>
<p>That makes more sense. And yeah, I don't think you want to change the <code>From</code> impl. I think you'd want to look at the <code>Try</code> impl, perhaps?</p>



<a name="195233606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233606">(Apr 24 2020 at 19:24)</a>:</h4>
<p>like we'd probably want a trait to be the hook for types that want to gather the locations</p>



<a name="195233659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233659">(Apr 24 2020 at 19:25)</a>:</h4>
<p>This also seems like a use case that ought to get fed into discussions of how <code>Try</code> should look. :)</p>



<a name="195233666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233666">(Apr 24 2020 at 19:25)</a>:</h4>
<p>yea, that was my plan for the RFC i intend to write for this</p>



<a name="195233679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233679">(Apr 24 2020 at 19:25)</a>:</h4>
<p>i've already talked to centril about this before</p>



<a name="195233684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233684">(Apr 24 2020 at 19:25)</a>:</h4>
<p>a little</p>



<a name="195233771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233771">(Apr 24 2020 at 19:26)</a>:</h4>
<p>FWIW, the <code>From</code> trick above is impressive, especially in how rapidly it produced a "yeet" reaction in me. ;)</p>



<a name="195233776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233776">(Apr 24 2020 at 19:26)</a>:</h4>
<p>I was just hoping I could abuse specialization and track caller to prototype this</p>



<a name="195233789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233789">(Apr 24 2020 at 19:26)</a>:</h4>
<p>ty ^_^</p>



<a name="195233819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233819">(Apr 24 2020 at 19:26)</a>:</h4>
<p>I think using track_caller is a completely sensible approach.</p>



<a name="195233824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233824">(Apr 24 2020 at 19:26)</a>:</h4>
<p>And what you're trying to do makes perfect sense.</p>



<a name="195233831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233831">(Apr 24 2020 at 19:26)</a>:</h4>
<p>but yea i agree it doesnt really make sense for From&lt;T&gt; -&gt; T to like, modify the type</p>



<a name="195233869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233869">(Apr 24 2020 at 19:27)</a>:</h4>
<p>At a minimum, you could prototype this with a <code>.trackme()</code> function.</p>



<a name="195233897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233897">(Apr 24 2020 at 19:27)</a>:</h4>
<p>yea but then it wouldnt work with <code>?</code> which is the whole point</p>



<a name="195233918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233918">(Apr 24 2020 at 19:27)</a>:</h4>
<p>Prototype. ;)</p>



<a name="195233925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233925">(Apr 24 2020 at 19:27)</a>:</h4>
<p>lol</p>



<a name="195233945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195233945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195233945">(Apr 24 2020 at 19:27)</a>:</h4>
<p>But yes, it makes sense to try to hook it into the <code>?</code> desugar.</p>



<a name="195234080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195234080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195234080">(Apr 24 2020 at 19:28)</a>:</h4>
<p>As another possibility, also using specialization, you could specialize <code>Try</code> for <code>Result&lt;T, YourErrorType&gt;</code>.</p>



<a name="195234114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195234114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195234114">(Apr 24 2020 at 19:28)</a>:</h4>
<p>oh shit</p>



<a name="195234129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195234129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195234129">(Apr 24 2020 at 19:29)</a>:</h4>
<p>To augment <code>YourErrorType</code> with the caller's location.</p>



<a name="195234136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195234136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195234136">(Apr 24 2020 at 19:29)</a>:</h4>
<p>no wait you cant do that with min_specialization</p>



<a name="195234180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195234180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195234180">(Apr 24 2020 at 19:29)</a>:</h4>
<p>Ill just make a unit type</p>



<a name="195234185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195234185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195234185">(Apr 24 2020 at 19:29)</a>:</h4>
<p>this is a good idea</p>



<a name="195234315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195234315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195234315">(Apr 24 2020 at 19:30)</a>:</h4>
<p>naw, still not coherent</p>



<a name="195234317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195234317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195234317">(Apr 24 2020 at 19:30)</a>:</h4>
<p>damnit</p>



<a name="195234347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195234347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195234347">(Apr 24 2020 at 19:30)</a>:</h4>
<p>oh but duh</p>



<a name="195234349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195234349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195234349">(Apr 24 2020 at 19:30)</a>:</h4>
<p>Another possibility would be <code>MyResult&lt;T&gt;</code> which is a "smart wrapper" around <code>Result&lt;T, MyError&gt;</code> (not just an alias).</p>



<a name="195234352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195234352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195234352">(Apr 24 2020 at 19:30)</a>:</h4>
<p>custom result</p>



<a name="195234354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195234354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195234354">(Apr 24 2020 at 19:30)</a>:</h4>
<p>yea</p>



<a name="195234376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195234376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195234376">(Apr 24 2020 at 19:30)</a>:</h4>
<p>smart wrapper?</p>



<a name="195234388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195234388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195234388">(Apr 24 2020 at 19:31)</a>:</h4>
<p>That's starting to get into more difficult to use territory, but it would work.</p>



<a name="195234406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195234406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195234406">(Apr 24 2020 at 19:31)</a>:</h4>
<p>(Right, because it's a Result but with some additional logic.)</p>



<a name="195234678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195234678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195234678">(Apr 24 2020 at 19:33)</a>:</h4>
<p>I dont think i need to implement all of the logic of result for the proof of concept</p>



<a name="195234713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195234713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195234713">(Apr 24 2020 at 19:33)</a>:</h4>
<p>gonna just implement the skeleton of the changes that I would need to make to implement this upstream</p>



<a name="195235816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195235816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195235816">(Apr 24 2020 at 19:42)</a>:</h4>
<p>BOOM</p>



<a name="195235826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195235826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195235826">(Apr 24 2020 at 19:42)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="n">error</span><span class="o">-</span><span class="k">return</span><span class="o">-</span><span class="n">trace</span><span class="w"> </span><span class="n">is</span><span class="w"> </span><span class="err">📦</span><span class="w"> </span><span class="n">v0</span><span class="p">.</span><span class="mf">1.0</span><span class="w"> </span><span class="n">via</span><span class="w"> </span><span class="err">🦀</span><span class="w"> </span><span class="n">v1</span><span class="p">.</span><span class="mf">44.0</span><span class="o">-</span><span class="n">nightly</span><span class="w"> </span><span class="n">took</span><span class="w"> </span><span class="mi">7</span><span class="n">m14s</span><span class="w"></span>
<span class="err">❯</span><span class="w"> </span><span class="n">cargo</span><span class="w"> </span><span class="n">run</span><span class="w"> </span><span class="o">--</span><span class="n">example</span><span class="w"> </span><span class="n">usage</span><span class="w"></span>
<span class="w">   </span><span class="n">Compiling</span><span class="w"> </span><span class="n">error</span><span class="o">-</span><span class="k">return</span><span class="o">-</span><span class="n">trace</span><span class="w"> </span><span class="n">v0</span><span class="p">.</span><span class="mf">1.0</span><span class="w"> </span><span class="p">(</span><span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">jlusby</span><span class="o">/</span><span class="n">git</span><span class="o">/</span><span class="n">rust</span><span class="o">/</span><span class="n">error</span><span class="o">-</span><span class="k">return</span><span class="o">-</span><span class="n">trace</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="n">Finished</span><span class="w"> </span><span class="n">dev</span><span class="w"> </span><span class="p">[</span><span class="n">unoptimized</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">debuginfo</span><span class="p">]</span><span class="w"> </span><span class="n">target</span><span class="p">(</span><span class="n">s</span><span class="p">)</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="mf">0.34</span><span class="n">s</span><span class="w"></span>
<span class="w">     </span><span class="n">Running</span><span class="w"> </span><span class="err">`</span><span class="n">target</span><span class="o">/</span><span class="n">debug</span><span class="o">/</span><span class="n">examples</span><span class="o">/</span><span class="n">usage</span><span class="err">`</span><span class="w"></span>
<span class="n">ReturnTrace</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">frames</span>: <span class="p">[</span><span class="n">Location</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">file</span>: <span class="s">&quot;examples/usage.rs&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">line</span>: <span class="mi">18</span><span class="p">,</span><span class="w"> </span><span class="n">col</span>: <span class="mi">42</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="n">Location</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">file</span>: <span class="s">&quot;examples/usage.rs&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">line</span>: <span class="mi">14</span><span class="p">,</span><span class="w"> </span><span class="n">col</span>: <span class="mi">16</span><span class="w"> </span><span class="p">}]</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>



<a name="195239326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195239326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195239326">(Apr 24 2020 at 20:15)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/issues/42327#issuecomment-619218371" title="https://github.com/rust-lang/rust/issues/42327#issuecomment-619218371">https://github.com/rust-lang/rust/issues/42327#issuecomment-619218371</a></p>



<a name="195258324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195258324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195258324">(Apr 25 2020 at 00:10)</a>:</h4>
<p>I think that with the current <code>Try</code> trait one could make this work  for a <code>MyResult</code> by looking up the caller location in <code>Try::into_result</code>.</p>
<p>But getting it on the wishlist for try trait v4 (or whatever we're on now) is probably the right thing for now.</p>



<a name="195263632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195263632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195263632">(Apr 25 2020 at 02:32)</a>:</h4>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span> I trust yall to remember this when designing the v4 Try trait and beyond</p>



<a name="195265727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195265727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195265727">(Apr 25 2020 at 03:35)</a>:</h4>
<p><span class="user-mention" data-user-id="220273">@Jane Lusby</span> You can also join the design meeting in a week and a bit, if you're interested: <a href="https://github.com/rust-lang/lang-team/#meeting-calendar" title="https://github.com/rust-lang/lang-team/#meeting-calendar">https://github.com/rust-lang/lang-team/#meeting-calendar</a></p>



<a name="195270714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195270714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195270714">(Apr 25 2020 at 06:21)</a>:</h4>
<p>Actually, since I'm apparently the one preparing for that meeting (<span aria-label="fear" class="emoji emoji-1f628" role="img" title="fear">:fear:</span>) do you have any thoughts on exactly which places you wanted to track the frames?  On <code>return Err(foo);</code>? On <code>yeet foo;</code>?  On a bubbling <code>?</code>?  When the propagation stops at a <code>try{}</code> block?  Etc.</p>



<a name="195290517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195290517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195290517">(Apr 25 2020 at 15:54)</a>:</h4>
<p>Preferably as much as possible</p>



<a name="195290525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195290525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195290525">(Apr 25 2020 at 15:54)</a>:</h4>
<p>Yeet and ? Should both do it for sure</p>



<a name="195290535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195290535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195290535">(Apr 25 2020 at 15:54)</a>:</h4>
<p>I'd really want every function boundary to do it but I don't think that's possible so this is going to have to be one of those best practice things</p>



<a name="195290561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195290561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195290561">(Apr 25 2020 at 15:55)</a>:</h4>
<p>It kinda sucks that you can lose frames by not explicitly proprogating the errors tho</p>



<a name="195290582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195290582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195290582">(Apr 25 2020 at 15:55)</a>:</h4>
<p>And I'm also worried about how you'd grab the last frame from where you catch it before reporting</p>



<a name="195290607"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195290607" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195290607">(Apr 25 2020 at 15:56)</a>:</h4>
<p>But if you return to main that's a non issue</p>



<a name="195428963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195428963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195428963">(Apr 27 2020 at 14:55)</a>:</h4>
<p><span class="user-mention silent" data-user-id="220273">Jane Lusby</span> <a href="#narrow/stream/213817-t-lang/topic/default.20from.20impl/near/195290561" title="#narrow/stream/213817-t-lang/topic/default.20from.20impl/near/195290561">said</a>:</p>
<blockquote>
<p>It kinda sucks that you can lose frames by not explicitly proprogating the errors tho</p>
</blockquote>
<p>this, I might add, is an argument of sorts for using some sort of fn-level sugar -- i.e., if you use Fehler and do</p>
<div class="codehilite"><pre><span></span><span class="cp">#[throws]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">u32</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">bar</span><span class="p">()</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">bar</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nb">Result</span><span class="o">&lt;</span><span class="kt">u32</span><span class="p">,</span><span class="w"> </span><span class="nb">Box</span><span class="o">&lt;</span><span class="n">dyn</span><span class="w"> </span><span class="n">Error</span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">..</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>


<p>you get an error, you have to call with <code>bar()?</code> (and thus you get the propagation).</p>



<a name="195429173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/default%20from%20impl/near/195429173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/default.20from.20impl.html#195429173">(Apr 27 2020 at 14:56)</a>:</h4>
<p>the other version of this is that it is confusing when the error types don't match, sometimes requiring <code>Ok(bar()?)</code> -- i.e., I tend to write code like that precisely to ensure more uniform handling of errors regardless</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>